-- @owner: opentestcase007
-- @date: 2020/9/1
-- @testpoint: opengauss关键字operator(非保留)，自定义操作符，操作符类 合理报错
-- @modified: by opentestcase007 2022/09/28 优化用例适配新代码
-- @modified: by opentestcase007 2023/04/20 优化用例,创建操作符族改用python用例实现
--下面的命令为数据类型box定义了一种新的操作符--面积相等：
DROP FUNCTION IF EXISTS area_equal_procedure() CASCADE;
CREATE OR REPLACE FUNCTION area_equal_procedure(box1 box, box2 box)
RETURNS boolean
AS $$
BEGIN
    RETURN (area(box1) - area(box2)) =0; -- 面积相等返回true
END;
$$ LANGUAGE plpgsql IMMUTABLE;
/
CREATE OPERATOR === (
    LEFTARG = box,
    RIGHTARG = box,
    PROCEDURE = area_equal_procedure,
    COMMUTATOR = ===,
    NEGATOR = !==,
    HASHES, MERGES
);
select box'(1,1),(2,2)' === box'(0,0),(1,1)';
DROP FUNCTION IF EXISTS area_equal_procedure() CASCADE;

--下面的例子命令为数据类型_int4(int4数组) 定义了一个 GiST 索引操作符类
CREATE OPERATOR CLASS gist__int_ops
    DEFAULT FOR TYPE _int4 USING gist AS
        OPERATOR        3       &&,
        OPERATOR        6       = (anyarray, anyarray),
        OPERATOR        7       @>,
        OPERATOR        8       <@,
        OPERATOR        20      @@ (_int4, query_int),
        FUNCTION        1       g_int_consistent (internal, _int4, int, oid, internal),
        FUNCTION        2       g_int_union (internal, internal),
        FUNCTION        3       g_int_compress (internal),
        FUNCTION        4       g_int_decompress (internal),
        FUNCTION        5       g_int_penalty (internal, internal, internal),
        FUNCTION        6       g_int_picksplit (internal, internal),
        FUNCTION        7       g_int_same (_int4, _int4, internal);

